def intToRoma(val):
    result=""
    now=val//1000
    left=val%1000
    result+="M"*now
    now=left//100
    left=left%100
    if now==9:
        result+="CM"
    elif now>=5:
        result+="D"
        result+="C"*(now-5)
    elif now==4:
        result+="CD"
    else:
        result+="C"*now
    now=left//10
    left=left%10
    if now==9:
        result+="XC"
    elif now>=5:
        result+="L"
        result+="X"*(now-5)
    elif now==4:
        result+="XL"
    else:
        result+="X"*now
    now=left
    if now==9:
        result+="IX"
    elif now>=5:
        result+="V"
        result+="I"*(now-5)
    elif now==4:
        result+="IV"
    else:
        result+="I"*now
    return result


print(intToRoma(1994))